<?php
/**
*
* @package phpBB SEO GYM Sitemaps
* @version $id: gym_yahoo.php - 3811 11-26-2008 16:07:48 - 2.0.RC2 dcz $
* @copyright (c) 2006 - 2008 www.phpbb-seo.com
* @license http://opensource.org/osi3.0/licenses/lgpl-license.php GNU Lesser General Public License
*
*/
// First basic security
if ( !defined('IN_PHPBB') ) {
	exit;
}
/**
* gym_yahoo Class
* www.phpBB-SEO.com
* @package phpBB SEO
*/
class gym_yahoo extends gym_sitemaps {
	/**
	* constuctor
	*/
	function gym_yahoo($action_type = 'yahoo') {
		global $phpbb_seo, $phpEx, $config;
		// Set up and check gzip handling
		$this->init_gzip();
		// Build the output
		$this->cache_config 	= array('cache_enable' => ( $this->gym_config['yahoo_cached'] ) ? TRUE : FALSE,
						'cache_auto_regen' => ( $this->gym_config['yahoo_cache_auto_regen'] ) ? TRUE : FALSE,
						'cache_force_gzip' => ( $this->gym_config['yahoo_cache_force_gzip'] ) ? TRUE : FALSE,
						'cache_born' => intval($this->gym_config['yahoo_cache_born']),
						'cache_max_age' => round($this->gym_config['yahoo_cache_max_age'],2) * 3600,
						'cache_gzip_ext'	=> ( $this->gym_config['yahoo_gzip'] || $this->gym_config['yahoo_cache_force_gzip'] ) ? '.xml.gz' : '.xml',
						'cached' => FALSE,
					);

		// Check the main vars
		$this->init_get_vars();
		// build cache file name 
		$file_name = $this->actions['action_type'] . md5( $this->actions['action_main'] . ( ( !empty($this->actions['action_sub']) ) ?  '_' . $this->actions['list_id'] : '' ) . $this->cache_config['cache_gzip_ext'];
		$this->cache_config['file'] = $this->path_config['module_path'] . 'cache/' . $file_name;
		$this->gym_setup_cache(); // Will exit in the cache is sent

		// Can you believe it, sprintf is faster than straight parsing. 
		$this->style_config	= array('Sitemap_tpl' => "\n\t" . '<url>' . "\n\t\t" . '<loc>%s</loc>' . "\n\t\t" . '<lastmod>%s</lastmod>' . "\n\t\t" . '<changefreq>%s</changefreq>' . "\n\t\t" . '<priority>%s</priority>' . "\n\t" . '</url>',
			'SitmIndex_tpl' => "\n\t" . '<sitemap>' . "\n\t\t" . '<loc>%s</loc>' . "\n\t\t" . '<lastmod>%s</lastmod>' . "\n\t" . '</sitemap>',
			'xslt_style' =>  : '',
			'stats_genlist'	=> "\n" . '<!-- URL list generated in  %s s %s - %s sql - %s URLs listed -->',
			'stats_start' => "\n" . '<!--  Output started from cache after %s s - %s sql -->',
			'stats_nocache'	=> "\n" . '<!--  Output ended after %s s %s -->',
			'stats_end' => "\n" . '<!--  Output from cache ended up after %s s - %s sql -->',
		);
		if ( empty($this->actions['module_main']) ) { // SitemapIndex
			$this->google_sitemapindex();
		} else { // Sitemap
			$this->google_sitemap();
		}
		return;
	}
	/**
	* GGs_yahoo() will build our urllist.txt to be submited at Yahoo.com
	* @access private
	*/
	function gym_yahoo() {
		global $phpEx, $db, $board_config, $phpbb_seo;
		// Initialize SQL cycling : do not query for more than required
		$this->yahoo_config['yahoo_sql_limit'] = ($this->yahoo_config['yahoo_sql_limit'] > $this->yahoo_config['yahoo_limit']) ? $this->yahoo_config['yahoo_limit'] : $this->yahoo_config['yahoo_sql_limit'];
		$this->output_data['showstats'] = FALSE;
		$this->mod_r_config['start'] = str_replace("&amp;", "&", $this->mod_r_config['start']);
		$dir = @opendir( $this->path_config['module_path'] . 'includes' );
		while( ($file = @readdir($dir)) !== FALSE ) {
			if( preg_match("/^yahoo_[a-zA-Z0-9_-]+\." . $phpEx . "$/", $file) ) {
				include_once($this->path_config['module_path'] . 'includes/' . $file);
			}
		}
		@closedir($dir);
		return;
	}
}
?>